﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GuiClient
{
    public partial class UserControlManHinhChuyenKhoan : UserControl
    {

        public delegate void Thoat();
        public event Thoat ThoatEvent;

        public delegate void XacNhanGiaoDich(String MaTheNguoiNhan,Double money);
        public event XacNhanGiaoDich XacNhanGiaoDichEvent;

        public UserControlManHinhChuyenKhoan()
        {
            InitializeComponent();
        }

        private void buttonXacNhanGiaoDich_Click(object sender, EventArgs e)
        {
            String MaThe="";
            Double Money=0;

            bool chuoiHopLe = true;
            Double money = 0;
            try
            {
                money = Convert.ToDouble(this.textBoxMoney.Text);
                if (money <= 0)
                {
                    chuoiHopLe = false;
                }
            }
            catch (Exception ex)
            {
                chuoiHopLe = false;
            }

            if (this.textBoxMaThe.Text.CompareTo("") == 0)
            {
                chuoiHopLe = false;
            }
            else
            {
                MaThe = this.textBoxMaThe.Text;
            }

            if (chuoiHopLe)
            {
                if (XacNhanGiaoDichEvent != null)
                {
                    XacNhanGiaoDichEvent(MaThe,money);
                }
            }
            else
            {
                MessageBox.Show("Bạn nhập không hợp lệ !");
            } 
        }

        private void buttonThoat_Click(object sender, EventArgs e)
        {
            if (ThoatEvent != null)
            {
                ThoatEvent();
            }
        }

        public void ResetGui()
        {
            this.textBoxMaThe.Text = "";
            this.textBoxMoney.Text = "";
        }

        private void UserControlManHinhChuyenKhoan_Load(object sender, EventArgs e)
        {

        }
    }
}
